package com.droidlogic.mboxlauncher;

import android.content.Context;
import android.util.ArrayMap;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.List;

public class AppLayout extends RelativeLayout {
    Animation animLeftIn;
    Animation animLeftOut;
    Animation animRightIn;
    Animation animRightOut;
    /* access modifiers changed from: private */
    public int currenPassword = 0;
    private MyGridLayout grid_layout;
    private ImageView icon;
    /* access modifiers changed from: private */
    public Context mContext;
    private int password = 0;
    private ImageView prompt;
    private TextView title;

    public AppLayout(Context context) {
        super(context);
        this.mContext = context;
    }

    public AppLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.mContext = context;
        initlayout();
    }

    public AppLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    private void initlayout() {
        inflate(this.mContext, R.layout.layout_second_screen, this);
        this.icon = (ImageView) findViewById(R.id.image_icon);
        this.prompt = (ImageView) findViewById(R.id.image_prompt);
        this.title = (TextView) findViewById(R.id.tx_title);
        this.grid_layout = (MyGridLayout) findViewById(R.id.gl_shortcut);
        this.animLeftIn = AnimationUtils.loadAnimation(this.mContext, R.anim.push_left_in);
        this.animLeftOut = AnimationUtils.loadAnimation(this.mContext, R.anim.push_left_out);
        this.animRightIn = AnimationUtils.loadAnimation(this.mContext, R.anim.push_right_in);
        this.animRightOut = AnimationUtils.loadAnimation(this.mContext, R.anim.push_right_out);
    }

    public void setLayout(int mode, List<ArrayMap<String, Object>> list) {
        switch (mode) {
            case 1:
                setImageAndText(R.drawable.video, R.drawable.prompt_video, R.string.str_video);
                break;
            case 2:
                setImageAndText(R.drawable.recommend, R.drawable.prompt_recommend, R.string.str_recommend);
                break;
            case 3:
                setImageAndText(R.drawable.music, R.drawable.prompt_music, R.string.str_music);
                break;
            case 4:
                setImageAndText(R.drawable.app, R.drawable.prompt_app, R.string.str_app);
                break;
            case 5:
                setImageAndText(R.drawable.local, R.drawable.prompt_local, R.string.str_local);
                break;
        }
        this.grid_layout.clearFocus();
        this.grid_layout.setLayoutView(mode, list);
        if (mode != 0 && this.grid_layout.getChildCount() > 0) {
            ((MyRelativeLayout) this.grid_layout.getChildAt(0)).requestFocus();
        }
    }

    public void setImageAndText(int resIcon, int resPrompt, int resTitle) {
        this.icon.setImageDrawable(this.mContext.getResources().getDrawable(resIcon));
        this.prompt.setImageDrawable(this.mContext.getResources().getDrawable(resPrompt));
        this.title.setText(resTitle);
    }

    public void setLayoutWithAnim(int animType, int mode, List<ArrayMap<String, Object>> list) {
        setLayout(mode, list);
        if (animType == 0) {
            this.animLeftIn.setAnimationListener(new MyAnimationListener(0, this.password));
            startAnimation(this.animLeftIn);
        } else {
            this.animRightIn.setAnimationListener(new MyAnimationListener(0, this.password));
            startAnimation(this.animRightIn);
        }
        this.password++;
    }

    private class MyAnimationListener implements Animation.AnimationListener {
        private int mPassword = -1;
        private int mType = -1;

        public MyAnimationListener(int type, int password) {
            this.mType = type;
            this.mPassword = password;
        }

        public void onAnimationStart(Animation animation) {
            ((Launcher) AppLayout.this.mContext).getHoverView().setVisibility(4);
            int unused = AppLayout.this.currenPassword = this.mPassword;
        }

        public void onAnimationEnd(Animation animation) {
            if (this.mType == 0 && AppLayout.this.currenPassword == this.mPassword) {
                ((Launcher) AppLayout.this.mContext).getHoverView().setVisibility(0);
            }
        }

        public void onAnimationRepeat(Animation animation) {
        }
    }
}